
-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure
-- --------------------------------------------------
-- Date Created: 06/08/2010 13:48:36
-- Generated from EDMX file: D:\Cleison\Meus_Documentos\Visual Studio 2010\Projects\ProjetoAllInOne\Projeto\AllInOne\AllInOne\Dados\ModeloDados.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO
USE [AllInOne];
GO
IF SCHEMA_ID(N'allinone') IS NULL EXECUTE(N'CREATE SCHEMA [allinone]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------

IF OBJECT_ID(N'[allinone].[FK_BairroCidade]', 'F') IS NOT NULL
    ALTER TABLE [allinone].[BairroSet] DROP CONSTRAINT [FK_BairroCidade];
GO
IF OBJECT_ID(N'[allinone].[FK_CidadeEstado]', 'F') IS NOT NULL
    ALTER TABLE [allinone].[CidadeSet] DROP CONSTRAINT [FK_CidadeEstado];
GO
IF OBJECT_ID(N'[allinone].[FK_UsuarioPermissao]', 'F') IS NOT NULL
    ALTER TABLE [allinone].[PessoaSet_Usuario] DROP CONSTRAINT [FK_UsuarioPermissao];
GO
IF OBJECT_ID(N'[allinone].[FK_FuncionarioCargo]', 'F') IS NOT NULL
    ALTER TABLE [allinone].[PessoaSet_Funcionario] DROP CONSTRAINT [FK_FuncionarioCargo];
GO
IF OBJECT_ID(N'[allinone].[FK_ServicoOrcamento_Servico]', 'F') IS NOT NULL
    ALTER TABLE [allinone].[ServicoOrcamento] DROP CONSTRAINT [FK_ServicoOrcamento_Servico];
GO
IF OBJECT_ID(N'[allinone].[FK_ServicoOrcamento_Orcamento]', 'F') IS NOT NULL
    ALTER TABLE [allinone].[ServicoOrcamento] DROP CONSTRAINT [FK_ServicoOrcamento_Orcamento];
GO
IF OBJECT_ID(N'[allinone].[FK_MaterialOrcamento_Material]', 'F') IS NOT NULL
    ALTER TABLE [allinone].[MaterialOrcamento] DROP CONSTRAINT [FK_MaterialOrcamento_Material];
GO
IF OBJECT_ID(N'[allinone].[FK_MaterialOrcamento_Orcamento]', 'F') IS NOT NULL
    ALTER TABLE [allinone].[MaterialOrcamento] DROP CONSTRAINT [FK_MaterialOrcamento_Orcamento];
GO
IF OBJECT_ID(N'[allinone].[FK_OrcamentoCliente]', 'F') IS NOT NULL
    ALTER TABLE [allinone].[OrcamentoSet] DROP CONSTRAINT [FK_OrcamentoCliente];
GO
IF OBJECT_ID(N'[allinone].[FK_ClienteEndereco]', 'F') IS NOT NULL
    ALTER TABLE [allinone].[ClienteSet] DROP CONSTRAINT [FK_ClienteEndereco];
GO
IF OBJECT_ID(N'[allinone].[FK_ClienteRepresentante]', 'F') IS NOT NULL
    ALTER TABLE [allinone].[ClienteSet] DROP CONSTRAINT [FK_ClienteRepresentante];
GO
IF OBJECT_ID(N'[allinone].[FK_EnderecoBairro]', 'F') IS NOT NULL
    ALTER TABLE [allinone].[EnderecoSet] DROP CONSTRAINT [FK_EnderecoBairro];
GO
IF OBJECT_ID(N'[allinone].[FK_OrcamentoFuncionario]', 'F') IS NOT NULL
    ALTER TABLE [allinone].[OrcamentoSet] DROP CONSTRAINT [FK_OrcamentoFuncionario];
GO
IF OBJECT_ID(N'[allinone].[FK_Usuario_inherits_Pessoa]', 'F') IS NOT NULL
    ALTER TABLE [allinone].[PessoaSet_Usuario] DROP CONSTRAINT [FK_Usuario_inherits_Pessoa];
GO
IF OBJECT_ID(N'[allinone].[FK_Funcionario_inherits_Usuario]', 'F') IS NOT NULL
    ALTER TABLE [allinone].[PessoaSet_Funcionario] DROP CONSTRAINT [FK_Funcionario_inherits_Usuario];
GO
IF OBJECT_ID(N'[allinone].[FK_Representante_inherits_Pessoa]', 'F') IS NOT NULL
    ALTER TABLE [allinone].[PessoaSet_Representante] DROP CONSTRAINT [FK_Representante_inherits_Pessoa];
GO

-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[allinone].[ClienteSet]', 'U') IS NOT NULL
    DROP TABLE [allinone].[ClienteSet];
GO
IF OBJECT_ID(N'[allinone].[EnderecoSet]', 'U') IS NOT NULL
    DROP TABLE [allinone].[EnderecoSet];
GO
IF OBJECT_ID(N'[allinone].[BairroSet]', 'U') IS NOT NULL
    DROP TABLE [allinone].[BairroSet];
GO
IF OBJECT_ID(N'[allinone].[CidadeSet]', 'U') IS NOT NULL
    DROP TABLE [allinone].[CidadeSet];
GO
IF OBJECT_ID(N'[allinone].[EstadoSet]', 'U') IS NOT NULL
    DROP TABLE [allinone].[EstadoSet];
GO
IF OBJECT_ID(N'[allinone].[PessoaSet]', 'U') IS NOT NULL
    DROP TABLE [allinone].[PessoaSet];
GO
IF OBJECT_ID(N'[allinone].[PermissaoSet]', 'U') IS NOT NULL
    DROP TABLE [allinone].[PermissaoSet];
GO
IF OBJECT_ID(N'[allinone].[CargoSet]', 'U') IS NOT NULL
    DROP TABLE [allinone].[CargoSet];
GO
IF OBJECT_ID(N'[allinone].[OrcamentoSet]', 'U') IS NOT NULL
    DROP TABLE [allinone].[OrcamentoSet];
GO
IF OBJECT_ID(N'[allinone].[ServicoSet]', 'U') IS NOT NULL
    DROP TABLE [allinone].[ServicoSet];
GO
IF OBJECT_ID(N'[allinone].[MaterialSet]', 'U') IS NOT NULL
    DROP TABLE [allinone].[MaterialSet];
GO
IF OBJECT_ID(N'[allinone].[PessoaSet_Usuario]', 'U') IS NOT NULL
    DROP TABLE [allinone].[PessoaSet_Usuario];
GO
IF OBJECT_ID(N'[allinone].[PessoaSet_Funcionario]', 'U') IS NOT NULL
    DROP TABLE [allinone].[PessoaSet_Funcionario];
GO
IF OBJECT_ID(N'[allinone].[PessoaSet_Representante]', 'U') IS NOT NULL
    DROP TABLE [allinone].[PessoaSet_Representante];
GO
IF OBJECT_ID(N'[allinone].[ServicoOrcamento]', 'U') IS NOT NULL
    DROP TABLE [allinone].[ServicoOrcamento];
GO
IF OBJECT_ID(N'[allinone].[MaterialOrcamento]', 'U') IS NOT NULL
    DROP TABLE [allinone].[MaterialOrcamento];
GO

-- --------------------------------------------------
-- Creating all tables
-- --------------------------------------------------

-- Creating table 'ClienteSet'
CREATE TABLE [allinone].[ClienteSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Nome] nvarchar(100)  NOT NULL,
    [CNPJ] bigint  NOT NULL,
    [Endereco_Id] int  NOT NULL,
    [Representante_Id] int  NOT NULL
);
GO

-- Creating table 'EnderecoSet'
CREATE TABLE [allinone].[EnderecoSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Logradouro] nvarchar(200)  NOT NULL,
    [Numero] smallint  NULL,
    [Complemento] nchar(100)  NULL,
    [CEP] int  NOT NULL,
    [Bairro_Id] int  NOT NULL
);
GO

-- Creating table 'BairroSet'
CREATE TABLE [allinone].[BairroSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Nome] nvarchar(100)  NOT NULL,
    [Cidade_Id] int  NOT NULL
);
GO

-- Creating table 'CidadeSet'
CREATE TABLE [allinone].[CidadeSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Nome] nvarchar(100)  NOT NULL,
    [Estado_Id] int  NOT NULL
);
GO

-- Creating table 'EstadoSet'
CREATE TABLE [allinone].[EstadoSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Nome] nvarchar(100)  NOT NULL,
    [UF] nchar(2)  NOT NULL
);
GO

-- Creating table 'PessoaSet'
CREATE TABLE [allinone].[PessoaSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Nome] nvarchar(100)  NOT NULL,
    [CPF] bigint  NOT NULL
);
GO

-- Creating table 'PermissaoSet'
CREATE TABLE [allinone].[PermissaoSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Nome] nvarchar(20)  NOT NULL,
    [Alterar] bit  NOT NULL,
    [Cadastrar] bit  NOT NULL,
    [Excluir] bit  NOT NULL,
    [Consultar] bit  NOT NULL
);
GO

-- Creating table 'CargoSet'
CREATE TABLE [allinone].[CargoSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Nome] nvarchar(30)  NOT NULL,
    [Descricao] nvarchar(150)  NULL
);
GO

-- Creating table 'OrcamentoSet'
CREATE TABLE [allinone].[OrcamentoSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Descricao] nvarchar(200)  NULL,
    [Data] datetime  NOT NULL,
    [ValorTotal] float  NULL,
    [Situacao] smallint  NOT NULL,
    [Nome] nvarchar(100)  NOT NULL,
    [Cliente_Id] int  NOT NULL,
    [Funcionario_Id] int  NOT NULL
);
GO

-- Creating table 'ServicoSet'
CREATE TABLE [allinone].[ServicoSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Nome] nvarchar(100)  NOT NULL,
    [Descricao] nvarchar(200)  NULL,
    [Valor] float  NOT NULL
);
GO

-- Creating table 'MaterialSet'
CREATE TABLE [allinone].[MaterialSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Nome] nvarchar(100)  NOT NULL,
    [Descricao] nvarchar(200)  NULL,
    [Valor] float  NOT NULL
);
GO

-- Creating table 'PessoaSet_Usuario'
CREATE TABLE [allinone].[PessoaSet_Usuario] (
    [Login] nvarchar(30)  NOT NULL,
    [Senha] nvarchar(30)  NOT NULL,
    [Situacao] smallint  NOT NULL,
    [Id] int  NOT NULL,
    [Permissao_Id] int  NOT NULL
);
GO

-- Creating table 'PessoaSet_Funcionario'
CREATE TABLE [allinone].[PessoaSet_Funcionario] (
    [IdCargo] int  NOT NULL,
    [Matricula] int  NOT NULL,
    [Id] int  NOT NULL
);
GO

-- Creating table 'PessoaSet_Representante'
CREATE TABLE [allinone].[PessoaSet_Representante] (
    [RG] int  NOT NULL,
    [Id] int  NOT NULL
);
GO

-- Creating table 'ServicoOrcamento'
CREATE TABLE [allinone].[ServicoOrcamento] (
    [Servico_Id] int  NOT NULL,
    [Orcamento_Id] int  NOT NULL
);
GO

-- Creating table 'MaterialOrcamento'
CREATE TABLE [allinone].[MaterialOrcamento] (
    [Material_Id] int  NOT NULL,
    [Orcamento_Id] int  NOT NULL
);
GO

-- --------------------------------------------------
-- Creating all PRIMARY KEY constraints
-- --------------------------------------------------

-- Creating primary key on [Id] in table 'ClienteSet'
ALTER TABLE [allinone].[ClienteSet]
ADD CONSTRAINT [PK_ClienteSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'EnderecoSet'
ALTER TABLE [allinone].[EnderecoSet]
ADD CONSTRAINT [PK_EnderecoSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'BairroSet'
ALTER TABLE [allinone].[BairroSet]
ADD CONSTRAINT [PK_BairroSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'CidadeSet'
ALTER TABLE [allinone].[CidadeSet]
ADD CONSTRAINT [PK_CidadeSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'EstadoSet'
ALTER TABLE [allinone].[EstadoSet]
ADD CONSTRAINT [PK_EstadoSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'PessoaSet'
ALTER TABLE [allinone].[PessoaSet]
ADD CONSTRAINT [PK_PessoaSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'PermissaoSet'
ALTER TABLE [allinone].[PermissaoSet]
ADD CONSTRAINT [PK_PermissaoSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'CargoSet'
ALTER TABLE [allinone].[CargoSet]
ADD CONSTRAINT [PK_CargoSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'OrcamentoSet'
ALTER TABLE [allinone].[OrcamentoSet]
ADD CONSTRAINT [PK_OrcamentoSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'ServicoSet'
ALTER TABLE [allinone].[ServicoSet]
ADD CONSTRAINT [PK_ServicoSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'MaterialSet'
ALTER TABLE [allinone].[MaterialSet]
ADD CONSTRAINT [PK_MaterialSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'PessoaSet_Usuario'
ALTER TABLE [allinone].[PessoaSet_Usuario]
ADD CONSTRAINT [PK_PessoaSet_Usuario]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'PessoaSet_Funcionario'
ALTER TABLE [allinone].[PessoaSet_Funcionario]
ADD CONSTRAINT [PK_PessoaSet_Funcionario]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'PessoaSet_Representante'
ALTER TABLE [allinone].[PessoaSet_Representante]
ADD CONSTRAINT [PK_PessoaSet_Representante]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Servico_Id], [Orcamento_Id] in table 'ServicoOrcamento'
ALTER TABLE [allinone].[ServicoOrcamento]
ADD CONSTRAINT [PK_ServicoOrcamento]
    PRIMARY KEY NONCLUSTERED ([Servico_Id], [Orcamento_Id] ASC);
GO

-- Creating primary key on [Material_Id], [Orcamento_Id] in table 'MaterialOrcamento'
ALTER TABLE [allinone].[MaterialOrcamento]
ADD CONSTRAINT [PK_MaterialOrcamento]
    PRIMARY KEY NONCLUSTERED ([Material_Id], [Orcamento_Id] ASC);
GO

-- --------------------------------------------------
-- Creating all FOREIGN KEY constraints
-- --------------------------------------------------

-- Creating foreign key on [Cidade_Id] in table 'BairroSet'
ALTER TABLE [allinone].[BairroSet]
ADD CONSTRAINT [FK_BairroCidade]
    FOREIGN KEY ([Cidade_Id])
    REFERENCES [allinone].[CidadeSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_BairroCidade'
CREATE INDEX [IX_FK_BairroCidade]
ON [allinone].[BairroSet]
    ([Cidade_Id]);
GO

-- Creating foreign key on [Estado_Id] in table 'CidadeSet'
ALTER TABLE [allinone].[CidadeSet]
ADD CONSTRAINT [FK_CidadeEstado]
    FOREIGN KEY ([Estado_Id])
    REFERENCES [allinone].[EstadoSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_CidadeEstado'
CREATE INDEX [IX_FK_CidadeEstado]
ON [allinone].[CidadeSet]
    ([Estado_Id]);
GO

-- Creating foreign key on [Permissao_Id] in table 'PessoaSet_Usuario'
ALTER TABLE [allinone].[PessoaSet_Usuario]
ADD CONSTRAINT [FK_UsuarioPermissao]
    FOREIGN KEY ([Permissao_Id])
    REFERENCES [allinone].[PermissaoSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_UsuarioPermissao'
CREATE INDEX [IX_FK_UsuarioPermissao]
ON [allinone].[PessoaSet_Usuario]
    ([Permissao_Id]);
GO

-- Creating foreign key on [IdCargo] in table 'PessoaSet_Funcionario'
ALTER TABLE [allinone].[PessoaSet_Funcionario]
ADD CONSTRAINT [FK_FuncionarioCargo]
    FOREIGN KEY ([IdCargo])
    REFERENCES [allinone].[CargoSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_FuncionarioCargo'
CREATE INDEX [IX_FK_FuncionarioCargo]
ON [allinone].[PessoaSet_Funcionario]
    ([IdCargo]);
GO

-- Creating foreign key on [Servico_Id] in table 'ServicoOrcamento'
ALTER TABLE [allinone].[ServicoOrcamento]
ADD CONSTRAINT [FK_ServicoOrcamento_Servico]
    FOREIGN KEY ([Servico_Id])
    REFERENCES [allinone].[ServicoSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Orcamento_Id] in table 'ServicoOrcamento'
ALTER TABLE [allinone].[ServicoOrcamento]
ADD CONSTRAINT [FK_ServicoOrcamento_Orcamento]
    FOREIGN KEY ([Orcamento_Id])
    REFERENCES [allinone].[OrcamentoSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_ServicoOrcamento_Orcamento'
CREATE INDEX [IX_FK_ServicoOrcamento_Orcamento]
ON [allinone].[ServicoOrcamento]
    ([Orcamento_Id]);
GO

-- Creating foreign key on [Material_Id] in table 'MaterialOrcamento'
ALTER TABLE [allinone].[MaterialOrcamento]
ADD CONSTRAINT [FK_MaterialOrcamento_Material]
    FOREIGN KEY ([Material_Id])
    REFERENCES [allinone].[MaterialSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Orcamento_Id] in table 'MaterialOrcamento'
ALTER TABLE [allinone].[MaterialOrcamento]
ADD CONSTRAINT [FK_MaterialOrcamento_Orcamento]
    FOREIGN KEY ([Orcamento_Id])
    REFERENCES [allinone].[OrcamentoSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_MaterialOrcamento_Orcamento'
CREATE INDEX [IX_FK_MaterialOrcamento_Orcamento]
ON [allinone].[MaterialOrcamento]
    ([Orcamento_Id]);
GO

-- Creating foreign key on [Cliente_Id] in table 'OrcamentoSet'
ALTER TABLE [allinone].[OrcamentoSet]
ADD CONSTRAINT [FK_OrcamentoCliente]
    FOREIGN KEY ([Cliente_Id])
    REFERENCES [allinone].[ClienteSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_OrcamentoCliente'
CREATE INDEX [IX_FK_OrcamentoCliente]
ON [allinone].[OrcamentoSet]
    ([Cliente_Id]);
GO

-- Creating foreign key on [Endereco_Id] in table 'ClienteSet'
ALTER TABLE [allinone].[ClienteSet]
ADD CONSTRAINT [FK_ClienteEndereco]
    FOREIGN KEY ([Endereco_Id])
    REFERENCES [allinone].[EnderecoSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_ClienteEndereco'
CREATE INDEX [IX_FK_ClienteEndereco]
ON [allinone].[ClienteSet]
    ([Endereco_Id]);
GO

-- Creating foreign key on [Representante_Id] in table 'ClienteSet'
ALTER TABLE [allinone].[ClienteSet]
ADD CONSTRAINT [FK_ClienteRepresentante]
    FOREIGN KEY ([Representante_Id])
    REFERENCES [allinone].[PessoaSet_Representante]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_ClienteRepresentante'
CREATE INDEX [IX_FK_ClienteRepresentante]
ON [allinone].[ClienteSet]
    ([Representante_Id]);
GO

-- Creating foreign key on [Bairro_Id] in table 'EnderecoSet'
ALTER TABLE [allinone].[EnderecoSet]
ADD CONSTRAINT [FK_EnderecoBairro]
    FOREIGN KEY ([Bairro_Id])
    REFERENCES [allinone].[BairroSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_EnderecoBairro'
CREATE INDEX [IX_FK_EnderecoBairro]
ON [allinone].[EnderecoSet]
    ([Bairro_Id]);
GO

-- Creating foreign key on [Funcionario_Id] in table 'OrcamentoSet'
ALTER TABLE [allinone].[OrcamentoSet]
ADD CONSTRAINT [FK_OrcamentoFuncionario]
    FOREIGN KEY ([Funcionario_Id])
    REFERENCES [allinone].[PessoaSet_Funcionario]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_OrcamentoFuncionario'
CREATE INDEX [IX_FK_OrcamentoFuncionario]
ON [allinone].[OrcamentoSet]
    ([Funcionario_Id]);
GO

-- Creating foreign key on [Id] in table 'PessoaSet_Usuario'
ALTER TABLE [allinone].[PessoaSet_Usuario]
ADD CONSTRAINT [FK_Usuario_inherits_Pessoa]
    FOREIGN KEY ([Id])
    REFERENCES [allinone].[PessoaSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Id] in table 'PessoaSet_Funcionario'
ALTER TABLE [allinone].[PessoaSet_Funcionario]
ADD CONSTRAINT [FK_Funcionario_inherits_Usuario]
    FOREIGN KEY ([Id])
    REFERENCES [allinone].[PessoaSet_Usuario]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Id] in table 'PessoaSet_Representante'
ALTER TABLE [allinone].[PessoaSet_Representante]
ADD CONSTRAINT [FK_Representante_inherits_Pessoa]
    FOREIGN KEY ([Id])
    REFERENCES [allinone].[PessoaSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------